export const getFileIcon = (name) => {
    const suffix = name.substring(name.lastIndexOf('.') + 1)
    let result = ''
    if (suffix === 'pdf') {
      result = 'file/pdf.png'
    } else if (suffix === 'doc' || suffix === 'docx') {
      result = 'file/doc.png'
    } else if (suffix === 'xls' || suffix === 'xlsx') {
      result = 'file/xls.png'
    } else if (suffix === 'ppt' || suffix === 'pptx') {
      result = 'file/ppt.png'
    } else if (suffix === 'txt') {
      result = 'file/txt.png'
    } else if (suffix === 'mp3') {
      result = 'file/mp3.png'
    } else if (suffix === 'rar' || suffix === 'zip') {
      result = 'file/rar.png'
    } else {
      result = 'file/unknown.png'
    }
    return process.env.VUE_APP_BASE + result
  }
  export const isImage = (name) => {
    const suffix = name.substring(name.lastIndexOf('.') + 1)
    return ['png', 'jpg', 'jpeg', 'gif'].includes(suffix.toLowerCase())
  }
  export const getFileSize = (size) => {
    if (size > 1099511627776) {
      return parseFloat(size / 1099511627776).toFixed(2) + 'TB'
    } else if (size > 1073741824) {
      return parseFloat(size / 1073741824).toFixed(2) + 'GB'
    } else if (size > 1048576) {
      return parseFloat(size / 1048576).toFixed(2) + 'MB'
    } else if (size > 1024) {
      return parseFloat(size / 1024).toFixed(2) + 'KB'
    } else {
      return size + 'B'
    }
  }
